package com.hsjk.szwj.module.mp.controller.app;

import com.hsjk.szwj.framework.common.pojo.CommonResult;
import com.hsjk.szwj.module.mp.controller.app.vo.AppMpRespVO;
import com.hsjk.szwj.module.mp.convert.MpConvert;
import com.hsjk.szwj.module.mp.dal.dataobject.MpConfigDO;
import com.hsjk.szwj.module.mp.service.IMpService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.annotation.security.PermitAll;

import static com.hsjk.szwj.framework.common.pojo.CommonResult.success;

/**
 * @author chenjiawei
 * @desc
 * @Date 2023/08/08 16:23
 **/
@Tag(name = "应用端 - 微信公众号相关接口")
@RestController
@RequestMapping("/mp")
@Validated
public class AppMpController {

    @Resource
    private IMpService mpService;

    @GetMapping("/get")
    @Operation(summary = "获取租户的公众号配置信息")
    @PermitAll
    public CommonResult<AppMpRespVO> getMp() {
        MpConfigDO systemMp = mpService.getMp();
        return success(MpConvert.INSTANCE.convertAppMpRespVO(systemMp));
    }
}
